/**
 * Copyright 2010 Victor Egea Hernando
 *
 * RockScript is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, version 3 of the License.
 * 
 * RockScript is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with RockScript.  If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef OBJECT_H_
#define OBJECT_H_

#include <vector>
#include <corelib/types.h>
#include <corelib/ucs/ustring.h>

#include "vmclass.h"
#include "vmtypes.h"

namespace paper{

class vmachine;

enum{
    FLG_BLOCKED_OBJECT = 1
};

/**
 * Most objects have to be named like: 
 * -> corelib.Object 
 *  
 * But there are special objects that cannot be extended, named just like this:
 * -> string, array, ibuffer, rbuffer, bbuffer
 */
class object{
	
public:
	// constructor
	object( vm_class *iclass );

	// main interface
	bool operator < ( const object *str ) const;
	vm_class *iclass( void ) const{ return _iclass; }

protected:
	// attributes
	std::vector<__register> _attribute;
	corelib::uint32 _flags;
	vm_class *_iclass;

	// friends
	friend class vmachine;
	
};

class oarray : public object{
	
public:
	// constructor
	oarray( vm_class *iclass );

protected:
	// attributes
	std::vector<__register> _arrayreg;

	// friends
	friend class vmachine;
	
};

class ostring : public object{
	
public:
	// constructors & destructor
	ostring( vm_class *iclass );
	ostring( vm_class *iclass, const corelib::ustring &str );

	// interface
	void set_string( const corelib::ustring &str );
	corelib::ustring &str( void );

protected:
	// attributes
	corelib::ustring _ustring;

	// friends
	friend class vmachine;
	
};

template <typename TYPE>
class obuffer : public object{
	
public:
	// constructor
	obuffer( vm_class *iclass ): object::object( iclass ){}

protected:
	// attributes
	std::vector<TYPE> _buffreg;

	// friends
	friend class vmachine;
	
};

}; // namespace paper;

#endif // OBJECT_H_

